﻿import React from 'react'
import { connect, actions, Router } from 'mirrorx'
import TopNav from './component/TopNav'
import Header from './component/Header'
import T from './lib/T' // 公共工具
import './lib/lazyLoadImg'
import './lib/iconfont' // 字体图标
import './sass/index.scss'// 样式
import PageRouter from './route/router'
import Loading from 'component/Loading'
import './model'

import { Layout } from 'antd'
const {Content} = Layout

window.T = T
window.LangMessage = window.LangMessage || {}

class App extends React.Component {
  componentDidMount () {
    actions.mainModel.requestUserInfo()
    actions.mainModel.requestVerificationState()
    actions.menuModel.getAllMenus()
  }

  shouldComponentUpdate () {
    return false
  }

  render () {
    const clientHeight = T.getScreenHeight()
    let {pathname} = window.location
    console.log('pathname', pathname)
    return (
      <Router forceRefresh={!('pushState' in window.history)}>
        <Layout style={{minHeight: clientHeight}}>
          {
            pathname === '/advertise'
            ? ''
            : <div>
              <Header />
              <TopNav />
            </div>
          }
          <Layout>
            <Content style={{'background': '#fff'}}>
              <PageRouter initProps={window.InitProps} />
            </Content>
          </Layout>
          <Loading />
        </Layout>
      </Router>
    )
  }
}

export default connect(state => {
  return state.mainModel
})(App)
